﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using MySql.Data.MySqlClient;

namespace DerptelligenceSite.Areas.Marein.Models.Blog
{
    public class BlogEntry
    {
        public UInt32 id { get; set; }
        public String title { get; set; }
        public String content { get; set; }
		public DateTime publishdate { get; set; }
        public String prettydate { get; set; }
        public BlogTopic topic { get; set; }
		public String tags { get; set; }
		public UInt32 comment_count { get; set; }
		public String url { get; set; }

		public BlogEntry( IDataRecord record )
		{
			id = (UInt32)record["id"];
			title = (String)record["title"];
			content = (String)record["content"];
			publishdate = (DateTime)record["publishdate"];
			prettydate = BlogText.PrettifyDateTime( publishdate );
			topic = BlogDatabase.GetTopicByShortTitle( (String)record["topic"] );
			tags = (String)record["tags"];
			comment_count = BlogDatabase.GetCommentCountByEntryID( id );
			url = VirtualPathUtility.ToAbsolute( "~/marein/blog/entry/" + id );
		}

		public BlogEntry()
		{

		}
    }
}